/*
 * Copyright (c) 2008 Benoit Bouchez, Nicolas Giard
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.noocodecommit.wicket.stuff.jquery.plugin.ui.tabs;

import com.noocodecommit.wicket.stuff.jquery.core.JQAjaxOptions;
import com.noocodecommit.wicket.stuff.jquery.plugin.JQPluginOptions;

/**
 * JQTabs Option set
 * 
 * @author Benoit Bouchez
 * 
 */
public class JQTabsOptions extends JQPluginOptions implements Cloneable
{
	private String selected = "0"; // null for all unselected
	private boolean unselect = false;
	private String event = "click";
	private int[] disabled;
	// TODO cookie dependency
	// cookie Object
	// Store the latest active (clicked) tab in a cookie. The cookie is used to determine the active tab on the next page load. Requires cookie plugin. The object needs to have key/value pairs of the form the cookie plugin expects as options.
	// Available options: { expires: 7, path: '/', domain: 'jquery.com', secure: true }
	// CodeStore active tab in a cookie that expires after 30 days.
	private String spinner = "Loading&#8230;";
	private boolean cache = false;
	private JQAjaxOptions ajaxOptions = new JQAjaxOptions();
	private String idPrefix = "ui-tabs-";
	private String fx;
	private String tabTemplate = "<li><a href='#{href}'><span>#{label}</span></a></li>";
	private String panelTemplate = "<div></div>";

	private String selectScript;
	private String loadScript;
	private String showScript;
	private String addScript;
	private String removeScript;
	private String enableScript;
	private String disableScript;

	/**
	 * Constructor
	 */
	public JQTabsOptions()
	{
		super();
		this.setDefaultHeader("tabs");
	}

	/**
	 * Gets the selected value
	 * 
	 * @return the selected value
	 */
	public String getSelected()
	{
		return selected;
	}

	/**
	 * Sets the seleted option value
	 * 
	 * @param selected
	 *            tab selected
	 */
	public void setSelected(String selected)
	{
		this.selected = selected;
		this.options.put("selected", "selected:" + selected);
	}

	/**
	 * Gets the unselect value
	 * 
	 * @return the unselect value
	 */
	public boolean isUnselect()
	{
		return unselect;
	}

	/**
	 * Sets the unselect option value
	 * 
	 * @param unselect
	 *            tab unselect
	 */
	public void setUnselect(boolean unselect)
	{
		this.unselect = unselect;
		this.options.put("unselect", "unselect:" + unselect);
	}

	/**
	 * Gets the event value
	 * 
	 * @return the event value
	 */
	public String getEvent()
	{
		return event;
	}

	/**
	 * Sets the event option value
	 * 
	 * @param event
	 *            tab event
	 */
	public void setEvent(String event)
	{
		this.event = event;
		this.options.put("event", "event:'" + event + "'");
	}

	/**
	 * Gets the disabled value
	 * 
	 * @return the disabled value
	 */
	public int[] getDisabled()
	{
		return disabled;
	}

	/**
	 * Sets the disabled option value
	 * 
	 * @param disabled
	 *            tab disabled
	 */
	public void setDisabled(int[] disabled)
	{
		this.disabled = disabled;
		this.options.put("disabled", "disabled:" + disabled);
	}

	/**
	 * Gets the spinner value
	 * 
	 * @return the spinner value
	 */
	public String getSpinner()
	{
		return spinner;
	}

	/**
	 * Sets the spinner option value
	 * 
	 * @param spinner
	 *            tab spinner
	 */
	public void setSpinner(String spinner)
	{
		this.spinner = spinner;
		this.options.put("spinner", "spinner:'" + spinner + "'");
	}

	/**
	 * Gets the cache value
	 * 
	 * @return the cache value
	 */
	public boolean isCache()
	{
		return cache;
	}

	/**
	 * Sets the cache option value
	 * 
	 * @param cache
	 *            tab cache
	 */
	public void setCache(boolean cache)
	{
		this.cache = cache;
		this.options.put("cache", "cache:" + cache);
	}

	/**
	 * Gets the ajaxOptions value
	 * 
	 * @return the ajaxOptions value
	 */
	public JQAjaxOptions getAjaxOptions()
	{
		return ajaxOptions;
	}

	/**
	 * Sets the ajaxOptions option value
	 * 
	 * @param ajaxOptions
	 *            tab ajaxOptions
	 */
	public void setAjaxOptions(JQAjaxOptions ajaxOptions)
	{
		this.ajaxOptions = ajaxOptions;
		this.options.put("ajaxOptions", "ajaxOptions:" + ajaxOptions.getDefaultString());
	}

	/**
	 * Gets the idPrefix value
	 * 
	 * @return the idPrefix value
	 */
	public String getIdPrefix()
	{
		return idPrefix;
	}

	/**
	 * Sets the idPrefix option value
	 * 
	 * @param idPrefix
	 *            tab idPrefix
	 */
	public void setIdPrefix(String idPrefix)
	{
		this.idPrefix = idPrefix;
		this.options.put("idPrefix", "idPrefix:'" + idPrefix + "'");
	}

	/**
	 * Gets the fx value
	 * 
	 * @return the fx value
	 */
	public String getFx()
	{
		return fx;
	}

	/**
	 * Sets the fx option value
	 * 
	 * @param fx
	 *            tab fx
	 */
	public void setFx(String fx)
	{
		this.fx = fx;
		this.options.put("fx", "fx:" + fx);
	}

	/**
	 * Gets the tabTemplate value
	 * 
	 * @return the tabTemplate value
	 */
	public String getTabTemplate()
	{
		return tabTemplate;
	}

	/**
	 * Sets the tabTemplate option value
	 * 
	 * @param tabTemplate
	 *            tab tabTemplate
	 */
	public void setTabTemplate(String tabTemplate)
	{
		this.tabTemplate = tabTemplate;
		this.options.put("tabTemplate", "tabTemplate:'" + tabTemplate + "'");
	}

	/**
	 * Gets the panelTemplate value
	 * 
	 * @return the panelTemplate value
	 */
	public String getPanelTemplate()
	{
		return panelTemplate;
	}

	/**
	 * Sets the panelTemplate option value
	 * 
	 * @param panelTemplate
	 *            tab panelTemplate
	 */
	public void setPanelTemplate(String panelTemplate)
	{
		this.panelTemplate = panelTemplate;
		this.options.put("panelTemplate", "panelTemplate:'" + panelTemplate + "'");
	}

	/**
	 * Gets the select script value
	 * 
	 * @return the select script value
	 */
	public String getSelectScript()
	{
		return selectScript;
	}

	/**
	 * Sets the select function
	 * 
	 * @param selectScript
	 *            tab select function
	 */
	public void setSelectScript(String selectScript)
	{
		this.selectScript = selectScript;
		this.options.put("select", "select:function(e, ui){" + selectScript + "}");
	}

	/**
	 * Gets the load script value
	 * 
	 * @return the load script value
	 */
	public String getLoadScript()
	{
		return loadScript;
	}

	/**
	 * Sets the load function
	 * 
	 * @param loadScript
	 *            tab load function
	 */
	public void setLoadScript(String loadScript)
	{
		this.loadScript = loadScript;
		this.options.put("load", "load:function(e, ui){" + loadScript + "}");
	}

	/**
	 * Gets the show script value
	 * 
	 * @return the show script value
	 */
	public String getShowScript()
	{
		return showScript;
	}

	/**
	 * Sets the show function
	 * 
	 * @param showScript
	 *            tab show function
	 */
	public void setShowScript(String showScript)
	{
		this.showScript = showScript;
		this.options.put("show", "show:function(e, ui){" + showScript + "}");
	}

	/**
	 * Gets the add script value
	 * 
	 * @return the add script value
	 */
	public String getAddScript()
	{
		return addScript;
	}

	/**
	 * Sets the add function
	 * 
	 * @param addScript
	 *            tab add function
	 */
	public void setAddScript(String addScript)
	{
		this.addScript = addScript;
		this.options.put("add", "add:function(e, ui){" + addScript + "}");
	}

	/**
	 * Gets the remove script value
	 * 
	 * @return the remove script value
	 */
	public String getRemoveScript()
	{
		return removeScript;
	}

	/**
	 * Sets the remove function
	 * 
	 * @param removeScript
	 *            tab remove function
	 */
	public void setRemoveScript(String removeScript)
	{
		this.removeScript = removeScript;
		this.options.put("remove", "remove:function(e, ui){" + removeScript + "}");
	}

	/**
	 * Gets the enable script value
	 * 
	 * @return the enable script value
	 */
	public String getEnableScript()
	{
		return enableScript;
	}

	/**
	 * Sets the enable function
	 * 
	 * @param enableScript
	 *            tab enable function
	 */
	public void setEnableScript(String enableScript)
	{
		this.enableScript = enableScript;
		this.options.put("enable", "enable:function(e, ui){" + enableScript + "}");
	}

	/**
	 * Gets the disable script value
	 * 
	 * @return the disable script value
	 */
	public String getDisableScript()
	{
		return disableScript;
	}

	/**
	 * Sets the disable function
	 * 
	 * @param disableScript
	 *            tab disable function
	 */
	public void setDisableScript(String disableScript)
	{
		this.disableScript = disableScript;
		this.options.put("disable", "disable:function(e, ui){" + disableScript + "}");
	}

	@Override
	protected Object clone() throws CloneNotSupportedException
	{
		JQTabsOptions clone = (JQTabsOptions) super.clone();
		return clone;
	}
}
